﻿using LX.Core.Utils;
using LX.Core.Validation;
using S4Store.Domain;
using S4Store.Persistent;
using System.Linq;

namespace S4Store.Service.Valid.CarValid
{
    public class CarBrandDelete : ValidExpression<CarBrand>
    {
        public S4StoreDataContext PersistentContext { get; set; }

        public override void ValidEntity(ValidationResult result, CarBrand entity)
        {
            if(!Helper.ArrayIsEmpty(entity.CarModels.ToList()))
            {
                PushError(result, "删除品牌前前请先删除属于此品牌的车款");
            }
        }
    }
}
